using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SnailPatrolState : BaseState
{
    public override void OnEnter(Enemy enemy) {
        Debug.Log("snail patrol");
        currentEnemy = enemy;
        currentEnemy.currentSpeed = currentEnemy.normalSpeed;
        currentEnemy.ani.SetBool("isWalk", true);
    }

    public override void LogicUpdate() {
        // 蜗牛如果发现Player则进入skill状态（隐藏）
        if (currentEnemy.FoundPlayer()) {
            currentEnemy.SwitchState(NPCState.Skill);
        }

        // 移动，如果撞墙则进入等待
        if (!currentEnemy.physicsCheck.isGround || (currentEnemy.physicsCheck.touchLeftWall && currentEnemy.faceDir.x < 0 || currentEnemy.physicsCheck.touchRightWall && currentEnemy.faceDir.x > 0)) {
            currentEnemy.isWait = true;
            currentEnemy.ani.SetBool("isWalk", false);
        } else {
            currentEnemy.isWait = false;
            currentEnemy.ani.SetBool("isWalk", true);
        }
    }

    public override void PhysicsUpdate() {
        
    }

    public override void OnExit() {
        currentEnemy.ani.SetBool("isWalk", false);
        Debug.Log("snail patrol exit");
    }

}